package com.suwish.pc.ui.preference;

import java.awt.Color;
import java.awt.event.MouseEvent;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JLabel;

/**
 * 
 * 
 * @author Min
 *
 */
public class PreferenceUI extends JLabel {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private Preference preference = null;
	
	public PreferenceUI(Preference preference){
		this.preference = preference;
		decorate();
		setIcon(preference.getIcon());
	    setText(preference.getTitle());
//	    setBackground(Color.green);
	    setToolTipText(preference.getToolTip());
	    setBorder(BorderFactory.createLineBorder(Color.green));
	}
	/**
     * Description: 鼠标选择重绘方法。
     * @param e
     * @author wq, 2009-8-27
     */
    public void mouseEntered(MouseEvent e) {
        if (this.isEnabled()) {
            this.invalidate();
            this.repaint();
        }
    }

    /**
     * Description: 面板底部加按钮。
     * 
     * @author wq, 2009-8-27
     */
    public void decorate() {
        this.setOpaque(true);

        this.setVerticalTextPosition(JButton.BOTTOM);
        this.setHorizontalTextPosition(JButton.CENTER);
    }
	public Preference getPreference(){
		return preference;
	}
}
